import request from '../utils/request'

export const GoodsList = 'wx/goods/list' // 获得商品列表
export function goodsList (query) {
  return request({
    url: GoodsList,
    method: 'get',
    params: query
  })
}
const GoodsDetail = 'wx/goods/detail' // 获得商品的详情
export function goodsDetail (query) {
  return request({
    url: GoodsDetail,
    method: 'get',
    params: query
  })
}

const CartCheckout = 'wx/cart/checkout' // 下单前信息确认
export function cartCheckout (query) {
  return request({
    url: CartCheckout,
    method: 'get',
    params: query
  })
}
const CartFastAdd = 'wx/cart/fastadd' // 立即购买商品
export function cartFastAdd (data) {
  return request({
    url: CartFastAdd,
    method: 'post',
    data
  })
}
const CartAdd = 'wx/cart/add' // 添加商品到购物车
export function cartAdd (data) {
  return request({
    url: CartAdd,
    method: 'post',
    data
  })
}
const CartAddList = 'wx/cart/addList' // 添加商品到购物车
export function cartAddList (data) {
  return request({
    url: CartAddList,
    method: 'post',
    data
  })
}
const CartList = 'wx/cart/index' // 获取购物车的数据
export function cartList (query) {
  return request({
    url: CartList,
    method: 'get',
    params: query
  })
}

const CartChecked = 'wx/cart/checked' // 选择或取消选择商品
export function cartChecked (data) {
  return request({
    url: CartChecked,
    method: 'post',
    data
  })
}

const CartUpdate = 'wx/cart/update' // 更新购物车的商品
export function cartUpdate (data) {
  return request({
    url: CartUpdate,
    method: 'post',
    data
  })
}
const CartDelete = 'wx/cart/delete' // 删除购物车的商品
export function cartDelete (data) {
  return request({
    url: CartDelete,
    method: 'post',
    data: {
      productIds: data
    }
  })
}

const CouponSelectList = 'wx/coupon/selectlist' // 当前订单可用优惠券列表
export function couponSelectList (query) {
  return request({
    url: CouponSelectList,
    method: 'get',
    params: query
  })
}

export const CouponMyList = 'wx/coupon/mylist' // 我的优惠券列表
export function couponMyList (query) {
  return request({
    url: CouponMyList,
    method: 'get',
    params: query
  })
}

const CouponExchange = 'wx/coupon/exchange' // 优惠券兑换
export function couponExchange (data) {
  return request({
    url: CouponExchange,
    method: 'post',
    data: {
      productIds: data
    }
  })
}
